<template>
  <div>
      <el-form label-position="left" label-width="100px" v-model="backgroundColor">
            <el-form-item  label="类型">
              <el-radio v-model="backgroundColor.option" label="pure">纯色</el-radio>
              <el-radio v-model="backgroundColor.option" label="linear">渐变</el-radio>
            </el-form-item>
            <el-form-item label="颜色" v-if="backgroundColor.option === 'pure'">
              <el-color-picker v-model="backgroundColor.pure" show-alpha size="small" @active-change="backgroundColorPure"></el-color-picker>
            </el-form-item>
            <el-divider content-position="center" v-if="backgroundColor.option === 'linear'">起始点</el-divider>
            <el-form-item  label="横坐标" v-if="backgroundColor.option === 'linear'">
                <el-input-number v-model="backgroundColor.linear.x" :min="0" :max="1" size="mini"/>
            </el-form-item>
            <el-form-item  label="纵坐标" v-if="backgroundColor.option === 'linear'">
                <el-input-number v-model="backgroundColor.linear.y" :min="0" :max="1" size="mini"/>
            </el-form-item>
            <el-divider content-position="center" v-if="backgroundColor.option === 'linear'">终止点</el-divider>
            <el-form-item  label="横坐标" v-if="backgroundColor.option === 'linear'">
                <el-input-number v-model="backgroundColor.linear.x2" :min="0" :max="1" size="mini"/>
            </el-form-item>
            <el-form-item  label="纵坐标" v-if="backgroundColor.option === 'linear'">
                <el-input-number v-model="backgroundColor.linear.y2" :min="0" :max="1" size="mini"/>
            </el-form-item>
            <el-form-item label="起始色" v-if="backgroundColor.option === 'linear'">
              <el-color-picker v-model="backgroundColor.linear.colorStops[0].color"  @active-change="backgroundColorLinearStart" show-alpha size="small"></el-color-picker>
            </el-form-item>
            <el-form-item label="终止色" v-if="backgroundColor.option === 'linear'">
              <el-color-picker v-model="backgroundColor.linear.colorStops[1].color"  @active-change="backgroundColorLinearEnd" show-alpha size="small"></el-color-picker>
            </el-form-item>
      </el-form>
      <el-form label-position="left" label-width="100px" v-model="detail">
        <el-divider content-position="center">其他</el-divider>
        <el-form-item label="图表动画">
          <el-radio v-model="detail.animation" :label="true">是</el-radio>
          <el-radio v-model="detail.animation" :label="false">否</el-radio>
        </el-form-item>
      </el-form>
  </div>
</template>

<script>

export default {
  methods: {
    backgroundColorPure (val) {
      this.backgroundColor.pure = val
      console.log(val)
    },
    backgroundColorLinearStart (val) {
      this.backgroundColor.linear.colorStops[0].color = val
    },
    backgroundColorLinearEnd (val) {
      this.backgroundColor.linear.colorStops[1].color = val
    }
  },
  computed: {
    detail () {
      return this.$store.state.layout[this.$store.state.activeArrayIndex].SlideContent[this.$store.state.insideActiveArrayIndex].itemContent.detail
    },
    backgroundColor () {
      return this.$store.state.layout[this.$store.state.activeArrayIndex].SlideContent[this.$store.state.insideActiveArrayIndex].itemContent.detail.backgroundColor
    }
  }
}
</script>

<style scoped>
    .el-form-item {
        margin-bottom: 0px
    }
</style>
